/*
 * @Author: hongbin
 * @Date: 2022-11-03 12:59:51
 * @LastEditors: hongbin
 * @LastEditTime: 2022-12-23 10:37:48
 * @Description:通过id查询用户信息
 */
import { ObjectId } from "mongodb";
import { NextApiRequest, NextApiResponse } from "next";
import DB from "../mongodb";

export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
    const db = await DB;
    const { id } = req.query;
    const user = await db.collection("userInfo").findOne({ _id: new ObjectId(id as string) });
    console.log(user);
    res.json(user);
}
